<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
    <head>
        <title>Title</title>
    </head>
    <body>
        <h1>商品列表</h1>
        <hr/>

        <c:if test="${empty user}">
            <%--未登录显示--%>
            <a href="${pageContext.request.contextPath}/shop/login.jsp">登录</a>
            <a href="${pageContext.request.contextPath}/shop/regist.jsp">注册</a>
        </c:if>

        <%--登录显示--%>
        <c:if test="${!empty user}">
            ${user.username}用户
            <a href="${pageContext.request.contextPath}/logout.user">注销</a>
            <a href="${pageContext.request.contextPath}/findByUserId.order">我的订单</a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前在线人数:${count}人
        </c:if>






        <br/>


        <table border="1">
            <tr>
                <th>序号</th>
                <th>商品</th>
                <th>单价</th>
                <th>操作</th>
            </tr>

            <c:forEach items="${products}" var="product" varStatus="s">
                <tr>
                    <td>${s.count}</td>
                    <td>${product.name}</td>
                    <td>${product.price}</td>
                    <td>
                        <a href="${pageContext.request.contextPath}/add.cart?productId=${product.id}">添加购物车</a>
                    </td>
                </tr>
            </c:forEach>


        </table>

        <a href="${pageContext.request.contextPath}/shop/cart.jsp">查看购物车</a>
    </body>
</html>


































